/*
 * @Author: chengyuan06 chengyuan06@baidu.com
 * @Date: 2023-02-26
 * @LastEditors: chengyuan06 chengyuan06@baidu.com
 * @LastEditTime: 2023-02-27
 * @FilePath: /归档/src/components/ImageUpload/utils.js
 * @Description: 文件上传的助手函数
 */

import axios from 'axios';

/*
 * @description 文件上传的函数
 * @params {File} file要上传的文件
 */
export const uploadFile = async file => {
    // 创建表单对象
    const data = new FormData();
    // 创建一个表单数据填充上传的文件
    data.append('file', file);

    const result = await axios({
        data,
        method: 'post',
        url: '/upload/uploadFile'
    });

    if (result.status === 0) {
        return {url: result.data || null};
    }
    
};
